package com.lanxin.oa.fiancial.service;

import com.lanxin.bean.BxInformaltype;
import com.lanxin.oa.fiancial.dao.ExpenseDao;
import com.lanxin.util.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ExpenseServiceImpl implements ExpenseService {

    @Autowired
    private ExpenseDao expenseDao;

    @Override
    public PageBean<BxInformaltype> getDeptPage(Integer page, Integer pageSize) {
        return expenseDao.selectBxInfoPage(page,pageSize);
    }

    @Override
    public void deleteBxInfo(Integer oid) {
        if(oid!=null &&!"".equals(oid)){
            BxInformaltype bxInformaltype=new BxInformaltype();
            bxInformaltype.setOid(oid);
            expenseDao.delete(bxInformaltype);
        }
    }

    @Override
    public void editBxInfo(BxInformaltype bxInfor) {
        expenseDao.saveOrUpdate(bxInfor);
    }

    @Override
    public boolean selectByBxInfoNameService(String name, Integer oid) {
        BxInformaltype bxInformaltype = expenseDao.selectByBxInfoName(name, oid);
        if (bxInformaltype != null) {
            return true;
        }
        return false;
    }

    @Override
    public BxInformaltype BxInforById(Integer oid) {
        return expenseDao.selectBxInFor(oid);
    }

    @Override
    public boolean updateBxInforState(Integer oid, String isActice) {
        BxInformaltype bxInformaltype = (BxInformaltype) expenseDao.getById(BxInformaltype.class, oid);
        bxInformaltype.setIsActice(isActice);
        expenseDao.update(bxInformaltype);
        return true;
    }
}
